package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSON;

import Dao.Daouser;
import Dao.impl.Daoimpluser;
import entity.Commodity;
import entity.Imgtype;
import entity.User;
import utils.javaben;
@WebServlet(name="denglu",urlPatterns="/denglu.do")
public class denglu extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		String yhm = request.getParameter("yhm");
		String mima = request.getParameter("mima");
		Daouser dao = new Daoimpluser();
		User user = dao.sel(yhm, mima);
		if(user==null){
			request.setAttribute("jie", 1);
			request.getRequestDispatcher("denglu.jsp").forward(request, response);
		}else{
			response.setContentType("text/html;charset=UTF-8");
			HttpSession session = request.getSession();
			session.setAttribute("che", user.getId());
			session.setAttribute("name", user.getName());
			request.getRequestDispatcher("shouye.do").forward(request, response);
		}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
